--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local steins__hy_hieda_no_akyuu = General:new(extension, "steins__hy_hieda_no_akyuu", "ten_k", 5, 5, General.Female)

    local tough_elbow = fk.CreateSkill {
        name = "tough_elbow",
    }
    tough_elbow:addEffect(fk.PreCardUse, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(tough_elbow.name, true) and data.from == player
        end,
        on_refresh = function(self, event, target, player, data)
            player.room:addPlayerMark(player, "tough_elbow-turn", 1)
        end
    })
    tough_elbow:addEffect(fk.CardUsing, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(tough_elbow.name, true) and data.from == player and (player:getMark("tough_elbow-turn") == 2 or player:getMark("tough_elbow-turn") == 4) and
                (data.card.trueName == "slash" or data.card.trueName == "duel")
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            if player:getMark("tough_elbow-turn") == 2 then
                data.extra_data = data.extra_data or {}
                data.extra_data.tough_elbow = true
                data.additionalDamage = (data.additionalDamage or 0) + 1
            else
                local targets = table.simpleClone(data.tos)
                table.removeOne(targets, player)
                local t
                if #targets == 1 then
                    t = targets[1]
                elseif #targets > 1 then
                    t = room:askToChoosePlayers(player, {
                        skill_name = tough_elbow.name,
                        prompt = "tough_elbow_prompt",
                        targets = targets,
                        min_num = 1,
                        max_num = 1,
                    })[1]
                end
                if t then
                    local cards = table.filter(t:getCardIds("h"), function(id)
                        return Fk:getCardById(id).type == Card.TypeBasic
                    end)
                    if #cards > 0 then
                        room:obtainCard(player, cards, false, fk.ReasonPrey, player, tough_elbow.name)
                    end
                end
            end
        end
    })
    tough_elbow:addEffect(fk.TargetSpecified, {
        can_refresh = function(self, event, target, player, data)
            return (data.extra_data or {}).tough_elbow
        end,
        on_refresh = function(self, event, target, player, data)
            data.to:addQinggangTag(data)
        end
    })

    local revive_contract = fk.CreateSkill {
        name = "revive_contract",
        tags = {
            Skill.Quest
        }
    }
    revive_contract:addEffect("active", {
        times = function(self, player)
            if player:getQuestSkillState(revive_contract.name) then
                return 0
            end
            return 3 - player:usedEffectTimes(revive_contract.name, Player.HistoryGame)
        end,
        card_num = 1,
        target_num = 0,
        target_filter = Util.FalseFunc,
        card_filter = function(self, player, to_select, selected, selected_targets)
            return #selected < 1 and Fk:getCardById(to_select).type ~= Card.TypeBasic
        end,
        can_use = function(self, player)
            return player:usedEffectTimes(revive_contract.name, Player.HistoryGame) < 3 and not player:getQuestSkillState(revive_contract.name) and player:isWounded()
        end,
        prompt = function(self, player, selected_cards, selected_targets)
            return "revive_contract_prompt"
        end,
        on_use = function(self, room, skillUseEvent)
            local player = skillUseEvent.from
            room:throwCard(skillUseEvent.cards, revive_contract.name, player, player)
            if not player.dead then
                room:recover({
                    who = player,
                    num = 1,
                    skillName = revive_contract.name
                })
            end
        end
    })
    revive_contract:addEffect(fk.Deathed, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(revive_contract.name) and not player:getQuestSkillState(revive_contract.name)
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:updateQuestSkillState(player, revive_contract.name, false)
            room:handleAddLoseSkills(player, "convict")
        end,
    })
    revive_contract:addEffect(fk.RoundEnd, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(revive_contract.name) and not player:getQuestSkillState(revive_contract.name) and player.hp <= player.room:getBanner("RoundCount")
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:updateQuestSkillState(player, revive_contract.name, true)
            room:handleAddLoseSkills(player, "inferno")
            room:addPlayerMark(player, "revive_contract_failed", 1)
        end,
    })
    revive_contract:addEffect("maxcards", {
        correct_func = function(self, player)
            if player:getMark("revive_contract_failed") ~= 0 then
                local value = -2
                local limit = 1
                local result = math.max(player.hp, 0)
                local status_skills = Fk:currentRoom().status_skills[MaxCardsSkill] or Util.DummyTable
                local max_fixed = nil
                for _, skill in ipairs(status_skills) do
                    local f = skill:getFixed(player)
                    if f ~= nil then
                        max_fixed = max_fixed and math.max(max_fixed, f) or f
                    end
                end
                if max_fixed then result = math.max(max_fixed, 0) end
                for _, skill in ipairs(status_skills) do
                    if skill ~= self then
                        local c = skill:getCorrect(player)
                        result = result + (c or 0)
                    end
                end
                value = (result + value < limit) and (limit - result) or value
                return math.min(value, 0)
            end
        end
    })

    extension:loadSkillSkels { tough_elbow, revive_contract }
    steins__hy_hieda_no_akyuu:addSkills { "tough_elbow", "revive_contract" }

    Fk:loadTranslationTable {
        ["steins__hy_hieda_no_akyuu"] = "稗田阿求",
        ["#steins__hy_hieda_no_akyuu"] = "帝王再诞",
        ["illustrator:steins__hy_hieda_no_akyuu"] = "AI",
        ["designer:steins__hy_hieda_no_akyuu"] = "黑曜人形",
        ["cv:steins__hy_hieda_no_akyuu"] = "",

        ["tough_elbow"] = "强肘",
        [":tough_elbow"] = "你每回合使用第二/四张牌时，若此牌为【杀】或【决斗】，你令之无视防具且伤害+1/获得其中一个目标手牌中所有基本牌。",
        ["tough_elbow_prompt"] = "强肘：获得其中一个目标手牌中所有基本牌",

        ["revive_contract"] = "冥契",
        [":revive_contract"] = "使命技，每局游戏限三次，出牌阶段，你可以弃置一张非基本牌并回复1点体力。<br>&nbsp;&nbsp;&nbsp;&nbsp;成功：其他角色死亡后，你获得“<a href = ':convict'>断罪</a>”。<br>&nbsp;&nbsp;&nbsp;&nbsp;失败：每轮结束时，若你的体力值不大于当前轮数，你的手牌上限-2（至少为1）并获得“<a href = ':inferno'>无间</a>”。",
        ["revive_contract_prompt"] = "冥契：你可以弃置一张非基本牌并回复1点体力",
    }
end
